#include "CSDLFontEngine.h"
#include "CSDLGraphics.h"
#include <SDL/SDL_ttf.h>
#include <iostream>


namespace FBShells
{
	CSDLFontEngine::CSDLFontEngine(CGraphics* parent) : CFontEngine(parent) {
		TTF_Init();
		std::string fontname = "FreeSerifA.ttf";
		m_currentFont = new CSDLFont(fontname,24);
	}

	CSDLFontEngine::~CSDLFontEngine() {
		TTF_Quit();
		delete m_currentFont;
	}

	void CSDLFontEngine::drawString(std::string pstring, int x, int y) {
		SDL_Surface* temptext = static_cast<CSDLFont*>(m_currentFont)->drawString(pstring);
		if(!temptext) std::cout<<"UGH"<<std::endl;
		SDL_Rect rcSrc, rcDst;
		rcSrc.w = temptext->w;
		rcSrc.h = temptext->h;
		rcSrc.x = 0;
		rcSrc.y = 0;
		rcDst = rcSrc;
		rcDst.x = x;
		rcDst.y = y;
	    SDL_BlitSurface(temptext,&rcSrc,static_cast<CSDLGraphics*>(m_parent)->GetScreen(),&rcDst);
	    SDL_FreeSurface(temptext);
	}
	
	void CSDLFontEngine::drawString(char* pstring, int x, int y) {
	}
	
	void CSDLFontEngine::drawChar(char pchar, int x, int y) {
	}
}
